package top.zlhy7.lock;

import java.util.concurrent.TimeUnit;

/**
 * @author renyong
 * @date 2022/8/3 20:37
 * @description 手机类，用于测试线程锁机制
 */
public class Phone {
    public void 普通方法1() {
        System.out.printf("%s,普通方法1\n",Thread.currentThread().getName());
    }
    public void 普通方法1_停4s() throws Exception{
        TimeUnit.SECONDS.sleep(4);
        System.out.printf("%s,普通方法1_停4s\n",Thread.currentThread().getName());
    }
    public void 普通方法2() {
        System.out.printf("%s,普通方法2\n",Thread.currentThread().getName());
    }
    public synchronized void 加锁_普通方法1() {
        System.out.printf("%s,加锁_普通方法1\n",Thread.currentThread().getName());
    }
    public synchronized void 加锁_普通方法2() {
        System.out.printf("%s,加锁_普通方法2\n",Thread.currentThread().getName());
    }
    public static void 静态方法1() {
        System.out.printf("%s,静态方法1\n",Thread.currentThread().getName());
    }
    public static void 静态方法2() {
        System.out.printf("%s,静态方法2\n",Thread.currentThread().getName());
    }
    public synchronized static void 解锁_静态方法1() {
        System.out.printf("%s,解锁_静态方法1\n",Thread.currentThread().getName());
    }
    public synchronized static void 解锁_静态方法2() {
        System.out.printf("%s,解锁_静态方法2\n",Thread.currentThread().getName());
    }
}
